package fms.webservice.server.util;

import org.apache.log4j.PropertyConfigurator;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

/**
 * @author hexun
 * @version $Date: 14-7-24 下午1:18 $
 *          加载log4就配置文件
 */
public class Log4jServlet extends HttpServlet {
    public void init() throws ServletException {
        String prefix = getServletContext().getRealPath("/");
        String file = getServletConfig().getInitParameter("log4j-config-file");
//        调试时：C:\tomcat\webapps\ROOT\WEB-INF\log4j.properties
//        System.out.println(prefix + file);
//        貌似log4j-config-file中配置正反斜杠都行
        if (file != null) {
            PropertyConfigurator.configure(prefix + file);
        }
    }
}